package com.letoo.sso.startup;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import com.letoo.sso.common.domain.ContextConstants;
import com.letoo.sso.core.service.AppBaseConfigService;

/**
 * 服务启动执行
 *
 * @author dengjie
 */
@Component
public class ConfigStartupRunner implements CommandLineRunner {
	/**
	 * 日志
	 */
	private final Logger log = LoggerFactory.getLogger(getClass());

	@Autowired
	private AppBaseConfigService appBaseConfigService;

	@Override
	public void run(String... args) throws Exception {
		loadDataToCache();
	}

	/**
	 * 将数据加载到缓存中
	 */
	public void loadDataToCache() {
		log.info("启动系统初始化APP基本配置信息到缓存中-------开始");
		appBaseConfigService.initAppBaseConfig(ContextConstants.APP_ID);
		log.info("启动系统初始化APP基本配置信息到缓存中-------结束");
	}
}
